<template>
  <div class="collect-page">
    <van-nav-bar fixed title="我的收藏" />
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <ArticleItems v-for="(item, i) in  renderData" :key="i" :data="item" />
    </van-list>
  </div>
</template>

<script>

import { getCollectOrLike } from '@/api/article'

export default {
  name: 'collect-page',
  data () {
    return {
      renderData: [],
      loading: false,
      finished: false,
      page: {
        page: 1,
        pageSize: 10,
        optType: 2
      }
    }
  },
  methods: {
    async onLoad () {
      const { data } = await getCollectOrLike(this.page)
      console.log(data)

      this.renderData = [...this.renderData, ...data.rows]
      this.page.page += 1
      this.loading = false

      if (this.page.page > data.pageTotal) {
        return (this.finished = true)
      }
    }

  }

}
</script>

<style lang="less" scoped>
.collect-page {
  margin-bottom: 50px;
  margin-top: 44px;
}
</style>
